<template>
	<div>
		<div class="publish-top">
			<div class="left-icon" @click="handleBack"> 
				<img src="../../../assets/images/left.png"/>
			</div>
			<p>我的帖子</p>
		</div>
		<div class="comment-content">
			<ul class="comment-list" v-if="isCommentsa">
				<li v-for="(item,index) in list" >
					<div class="list-left">
						<h1>{{item.time1}}</h1>
						<p>{{item.time2}}月</p>
					</div>
					<div class="list-right">
						<div class="right-top">
							<img  class="delete" src="../../../assets/images/mine/delete.png" @click="handleDelete(item.article_id,index)"/> 
							<!--<div class="privacy">
								<img src="../../../assets/images/mine/suo.jpg"/>
								<span>仅自己</span>
							</div>-->
						</div>
						<div class="con" @click="handleDetal (item.article_id)">
							<img :src="item.article_img[0]" v-if="item.article_img !=''"/>
							<div class="con-desc">{{item.article_title}}</div>
						</div>
						<div class="bottom-list">
							<div class="box">
								<img src="../../../assets/images/mine/mine-comment.png"/>
								<span class="">{{item.article_comment_num}}</span>
							</div>
							<div class="box">
								<img src="../../../assets/images/mine/up.png"/>
								<span class="">{{item.article_like_num}}</span>
							</div>
							<div class="box">
								<img src="../../../assets/images/mine/down.png"/>
								<span class="">{{item.article_step_num}}</span>
							</div>
						</div>
					</div>
				</li>
			</ul>
			<div class="list-img-pic" v-else>
				<nocontent></nocontent>
			</div>
		</div>
	</div>
</template>

<script>
	import axios from "axios";
	import user from '../../../utils/isLogin';
	import Nocontent from '@/components/home/no-content';
	export default{
		data(){
			return{
				list:[],
				isClick:true,
				isCommentsa:true
			}
		},
		filters: {
		  url: function (value) {
		    if (!value) return ''
		    value = user.src + value
		    return value
		  }
		},
		components:{
			Nocontent
		},
		created(){

			var userId = JSON.parse(window.localStorage.getItem( 'userInfo' )).userId;
	    	axios.post(user.src+ '/index/my/my_post' , {
				userid: userId,
			})
			.then((res)=> {
				
				if(res.data.status == 1049){
					this.isCommentsa = false;
				}
				if(res.data.status == 200){
					var list = res.data.data;
					list.map((ele,index)=>{
						var arr = ele.article_time.split(' ');
						ele.time1 = arr[0].split('-')[2];
						ele.time2 = arr[0].split('-')[1];
					})
					this.list = list;
					this.isCommentsa = true;
				}
			})
			.catch((error)=> {	   
			});
			
			
			let plusReady = ()=>{
				
			}
			if (window.plus) {
	      	plusReady();
	    	} else {
	     		document.addEventListener("plusready", plusReady, false);
	   	}
		},
		methods:{
			handleBack(){
				var comments = plus.webview.currentWebview();
				plus.webview.close(comments);
			},
			handleDelete(id,index){
				axios.post(user.src + '/index/my/delete_posts' , {
					articled: id,
				})
				.then((res)=> {
					if(res.data.status == 200){
						this.list.splice(index, 1);
						plus.webview.getWebviewById('mine').reload();
					}else{
						plus.nativeUI.toast('删除失败')
					}
				})
				.catch( (error)=> {   
				});
			},
			handleDetal(id){
				if(this.isClick){
					this.isClick = false;
					var postDetails = plus.webview.create('postDetails.html','postDetails',{scrollIndicator:'none'},{
						articleId:id,
						type:1
					});
					postDetails.addEventListener("loaded", ()=> {
					    postDetails.show('pop-in', 300);
					    this.isClick = true;
					    postDetails = null;
					}, false);
				}
			}
		}
	}
</script>

<style lang='less'>
	
html,body{
	padding: 0;
	margin: 0;
	width: 100%;
	height: 100%;
	background: #fff;
}
*{
	margin: 0;
	padding: 0;
}
ul,li{
	list-style: none;
}
.publish-top{
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 60px;
	background:@default-blue;
	box-shadow: 0px 0px 8px 1px #999;
	padding-top: 70px;
	display:flex;				
	.left-icon{
		width: 90px;
		
		img{
			width: 15px;
			height: 26px;
			margin-left: 31px;
		}
	}
	p{		
		width: 80%;
		color: #fff;
		font-size: 28px;
		text-align: center;
	}
	span{
		display: block;
		width: 170px;
		color: #fff;
		font-size: 28px;
		text-align: center;
	}
}
.comment-content{
	padding-top: 130px;
	width: 100%;
	.comment-list{
		width:100%;
		li{
			padding: 30px 23px 30px 36px;
			margin-bottom: 12px;
			background: #fff;
			display: flex;
			flex-wrap: nowrap;
			.list-left{
				width:72px;
				height: 264px;
				h1{
					line-height: 35px;
					font-size: 35px;
					color: #000;
				}
				p{
				 	padding-left: 8px;
				 	font-size: 18px;
				 	color: #6c6c6c;
				}
			}
			.list-right{
				width: 614px;
				.right-top{
					height: 52px;
					overflow: hidden;
					.privacy{
						padding: 0 12px;
						float: right;
						width: 94px;
						height: 30px;
						img{
							float: left;
							margin-top: 5px;
							display: block;
							width: 20px;
							height: 20px;
						}
						span{
							float: right;
							font-size: 20px;
							color: #999999;
							line-height: 30px;
						}
					}
					.delete{
						padding: 4px;
						float: right;
						display: block;
						width: 22px;
						height: 22px;
					}
					
				}
				.con{
					overflow: hidden;
					background: #eeeef0;
					border-radius: 10px;
					display: flex;
					align-items: center;
					img{
						display: block;
						float: left;
						width: 174px;
						height: 140px;
						border-radius: 10px;
					}
					.con-desc{
						float: left;
						padding: 18px 0 20px 14px;
						font-size: 22px;
						color: #333;	
					}
				}
				.bottom-list{
					margin-top: 40px;
					display: flex;
					justify-content: space-around;
					.box{
						display: flex;
						img{
							display: block;
							width: 30px;
							height: 30px;
						}
						span{
							margin-left: 20px;
							display: block;
							font-size: 22px;
							color: #666666;
						}
					}
				}
			}
		}
	}
}
.list-img-pic{
	height: 800px;
	display: flex;
	justify-content: center;
	align-items: center;
}
</style>